package com.sneaker.shower.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Arrays;

/**
 * @author Hechangjian
 * @version 1.0
 * @className CouponTypeEnums
 * @date 2019/11/26 14:57
 * @description 优惠券枚举
 * @program bath
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum CouponTypeEnums {
    // 优惠券类型 1，免单券， 2折扣券，3现金券

    FREE_COUPON(1, "免单券"),
    DISCOUNT_COUPON(2, "折扣券"),
    CASH_COUPON(3, "现金券"),
    DEFAULT(100, null);

    private int code;

    private String name;

    public static String getNameByCode(Integer code) {
        return Arrays.stream(CouponTypeEnums.values()).filter(c -> c.code == code).findFirst().orElse(DEFAULT).name;
    }
}